package com.devicestatus.dao;

import com.devicestatus.entity.Device;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author MeowParse
 * @date 2017/8/14.
 */
public interface DeviceDao extends JpaRepository<Device,String> {

	@Query(value = "select mac from device where product_id = ?",nativeQuery = true)
	List<String> getMacs(String productId);

	@Query(value = "update device set online = ? where id = ?" ,nativeQuery = true)
	@Transactional
	@Modifying
	void updateOnline(int online,String id);

}
